# !/usr/bin/python
# -*- coding: UTF-8 -*-
"""
@author:zzly
@file:serializers.py
@time:2020/09/08
"""
from rest_framework import serializers
from apps.worker.models import Worker
from apps.member.serializers import MemeberInfoAppSerializer


class WorkerAppSeializer(serializers.ModelSerializer):
    face_path = serializers.SerializerMethodField(read_only=True)

    def get_face_path(self, obj):
        if obj.face:
            return obj.face.get_url()
        return ''

    class Meta:
        model = Worker
        fields = ('id', 'name', 'age', 'skills', 'start', 'work_age', 'case_count', 'face_path')
